﻿using QL_DTTN.DTO.DTO;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace QL_DTTN.TTKT.BUS
{
    public static class KyThi_Bus
    {
        public static string Them(KyThi kyThi, List<MonThi> lstMonThi, List<ChiTietMonThi> lstChiTiet)
        {
            string kq = "";
            long ma = Convert.ToInt64(new KyThi().Them(kyThi));
            if (ma > 0)
            {
                foreach (var m in lstMonThi)
                {
                    m.MaKyThi = ma;
                    bool kt = new MonThi().Them(m, lstChiTiet.Where(c => c.MaMonThi == m.MaMon).ToList());
                    if (!kt)
                    {
                        kq += "thêm thất bại môn thi: " + m.MaMon + "\n";
                    }
                }
            }
            return kq;
        }
        public static DataTable dataTable()
        {
            return new KyThi().selectAll();
        }
    }
}
